/*
 * @Description: 系统字段
 * @Author: june
 */
import request from "@/utils/request";

// 新增
export function systemFieldSave(systemFieldAddDTO) {
  return request({
    url: "/config/api/v1/systemFields",
    method: "post",
    data: systemFieldAddDTO
  });
}

// 修改
export function systemFieldUpdate(systemFieldUpdateDTO) {
  return request({
    url: "/config/api/v1/systemFields",
    method: "put",
    data: systemFieldUpdateDTO
  });
}

// 单个删除
export function systemFieldDelete(systemFieldId) {
  return request({
    url: `/config/api/v1/systemFields/${systemFieldId}`,
    method: "delete"
  });
}

// 批量删除
export function systemFieldDeleteBatch(systemFieldIds) {
  return request({
    url: "/config/api/v1/systemFields",
    method: "delete",
    data: systemFieldIds
  });
}

// 根据id查找
export function systemFieldFindById(systemFieldId) {
  return request({
    url: `/config/api/v1/systemFields/${systemFieldId}`,
    method: "get"
  });
}

// 查找所有
export function systemFieldListAll(systemFieldQuery) {
  return request({
    url: "/config/api/v1/systemFields/listAll",
    method: "get",
    params: systemFieldQuery
  });
}

// 分页查询
export function systemFieldPage(systemFieldQuery) {
  let ordersParam = "";
  if (systemFieldQuery.orders) {
    systemFieldQuery.orders.forEach((order, index) => {
      const op = "orders[" + index + "]";
      if (ordersParam !== "") {
        ordersParam += "&";
      }
      ordersParam += op + ".property=" + order.property + "&" + op + ".desc=" + order.desc;
    });
    systemFieldQuery.orders = undefined;
  }
  return request({
    url: "/config/api/v1/systemFields?" + ordersParam,
    method: "get",
    params: systemFieldQuery
  });
}
